.class public Lcom/brixd/niceapp/service/adapter/JsonObjectConverter;
.super Ljava/lang/Object;
.source "JsonObjectConverter.java"

# interfaces
.implements Lretrofit/converter/Converter;


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/brixd/niceapp/service/adapter/JsonObjectConverter$JsonTypedOutput;
    }
.end annotation


# instance fields
.field private encoding:Ljava/lang/String;


# direct methods
.method public constructor <init>()V
    .registers 2

    .prologue
    .line 43
    const-string v0, "UTF-8"

    invoke-direct {p0, v0}, Lcom/brixd/niceapp/service/adapter/JsonObjectConverter;-><init>(Ljava/lang/String;)V

    .line 44
    return-void
.end method

.method public constructor <init>(Ljava/lang/String;)V
    .registers 2
    .param p1, "encoding"    # Ljava/lang/String;

    .prologue
    .line 46
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 47
    iput-object p1, p0, Lcom/brixd/niceapp/service/adapter/JsonObjectConverter;->encoding:Ljava/lang/String;

    .line 48
    return-void
.end method


# virtual methods
.method public fromBody(Lretrofit/mime/TypedInput;Ljava/lang/reflect/Type;)Ljava/lang/Object;
    .registers 11
    .param p1, "body"    # Lretrofit/mime/TypedInput;
    .param p2, "type"    # Ljava/lang/reflect/Type;
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lretrofit/converter/ConversionException;
        }
    .end annotation

    .prologue
    .line 52
    const-string v1, "UTF-8"

    .line 53
    .local v1, "charset":Ljava/lang/String;
    invoke-interface {p1}, Lretrofit/mime/TypedInput;->mimeType()Ljava/lang/String;

    move-result-object v6

    if-eqz v6, :cond_10

    .line 54
    invoke-interface {p1}, Lretrofit/mime/TypedInput;->mimeType()Ljava/lang/String;

    move-result-object v6

    invoke-static {v6}, Lretrofit/mime/MimeUtil;->parseCharset(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v1

    .line 57
    :cond_10
    :try_start_10
    invoke-interface {p1}, Lretrofit/mime/TypedInput;->in()Ljava/io/InputStream;

    move-result-object v6

    invoke-static {v6, v1}, Lcom/zuiapps/suite/utils/string/StringUtils;->inputSteamToString(Ljava/io/InputStream;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v4

    .line 58
    .local v4, "json":Ljava/lang/String;
    const-string v6, "Json Object Converter"

    invoke-static {v6, v4}, Lcom/zuiapps/suite/utils/log/LogUtil;->i(Ljava/lang/String;Ljava/lang/String;)V

    .line 60
    new-instance v5, Lorg/json/JSONObject;

    invoke-direct {v5, v4}, Lorg/json/JSONObject;-><init>(Ljava/lang/String;)V

    .line 61
    .local v5, "jsonObject":Lorg/json/JSONObject;
    const-string v6, "result"

    invoke-virtual {v5, v6}, Lorg/json/JSONObject;->optInt(Ljava/lang/String;)I

    move-result v6

    const/4 v7, 0x1

    if-ne v6, v7, :cond_82

    .line 62
    const-string v6, "data"

    invoke-virtual {v5, v6}, Lorg/json/JSONObject;->has(Ljava/lang/String;)Z

    move-result v6

    if-eqz v6, :cond_70

    .line 63
    const-string v6, "data"

    invoke-virtual {v5, v6}, Lorg/json/JSONObject;->optJSONObject(Ljava/lang/String;)Lorg/json/JSONObject;
    :try_end_38
    .catch Ljava/io/IOException; {:try_start_10 .. :try_end_38} :catch_8a
    .catch Lcom/google/gson/JsonParseException; {:try_start_10 .. :try_end_38} :catch_9a
    .catch Lorg/json/JSONException; {:try_start_10 .. :try_end_38} :catch_a1
    .catchall {:try_start_10 .. :try_end_38} :catchall_91

    move-result-object v2

    .line 64
    .local v2, "dataObj":Lorg/json/JSONObject;
    if-eqz v2, :cond_48

    .line 92
    :try_start_3b
    invoke-interface {p1}, Lretrofit/mime/TypedInput;->in()Ljava/io/InputStream;

    move-result-object v6

    invoke-virtual {v6}, Ljava/io/InputStream;->close()V
    :try_end_42
    .catch Ljava/io/IOException; {:try_start_3b .. :try_end_42} :catch_43

    .line 95
    .end local v2    # "dataObj":Lorg/json/JSONObject;
    :goto_42
    return-object v2

    .line 93
    .restart local v2    # "dataObj":Lorg/json/JSONObject;
    :catch_43
    move-exception v3

    .line 94
    .local v3, "e":Ljava/io/IOException;
    invoke-virtual {v3}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_42

    .line 67
    .end local v3    # "e":Ljava/io/IOException;
    :cond_48
    :try_start_48
    const-string v6, "data"

    invoke-virtual {v5, v6}, Lorg/json/JSONObject;->optJSONArray(Ljava/lang/String;)Lorg/json/JSONArray;
    :try_end_4d
    .catch Ljava/io/IOException; {:try_start_48 .. :try_end_4d} :catch_8a
    .catch Lcom/google/gson/JsonParseException; {:try_start_48 .. :try_end_4d} :catch_9a
    .catch Lorg/json/JSONException; {:try_start_48 .. :try_end_4d} :catch_a1
    .catchall {:try_start_48 .. :try_end_4d} :catchall_91

    move-result-object v0

    .line 68
    .local v0, "array":Lorg/json/JSONArray;
    if-eqz v0, :cond_5e

    .line 92
    :try_start_50
    invoke-interface {p1}, Lretrofit/mime/TypedInput;->in()Ljava/io/InputStream;

    move-result-object v6

    invoke-virtual {v6}, Ljava/io/InputStream;->close()V
    :try_end_57
    .catch Ljava/io/IOException; {:try_start_50 .. :try_end_57} :catch_59

    :goto_57
    move-object v2, v0

    .line 95
    goto :goto_42

    .line 93
    :catch_59
    move-exception v3

    .line 94
    .restart local v3    # "e":Ljava/io/IOException;
    invoke-virtual {v3}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_57

    .line 71
    .end local v3    # "e":Ljava/io/IOException;
    :cond_5e
    :try_start_5e
    new-instance v2, Lorg/json/JSONObject;

    .end local v2    # "dataObj":Lorg/json/JSONObject;
    invoke-direct {v2}, Lorg/json/JSONObject;-><init>()V
    :try_end_63
    .catch Ljava/io/IOException; {:try_start_5e .. :try_end_63} :catch_8a
    .catch Lcom/google/gson/JsonParseException; {:try_start_5e .. :try_end_63} :catch_9a
    .catch Lorg/json/JSONException; {:try_start_5e .. :try_end_63} :catch_a1
    .catchall {:try_start_5e .. :try_end_63} :catchall_91

    .line 92
    :try_start_63
    invoke-interface {p1}, Lretrofit/mime/TypedInput;->in()Ljava/io/InputStream;

    move-result-object v6

    invoke-virtual {v6}, Ljava/io/InputStream;->close()V
    :try_end_6a
    .catch Ljava/io/IOException; {:try_start_63 .. :try_end_6a} :catch_6b

    goto :goto_42

    .line 93
    :catch_6b
    move-exception v3

    .line 94
    .restart local v3    # "e":Ljava/io/IOException;
    invoke-virtual {v3}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_42

    .line 78
    .end local v0    # "array":Lorg/json/JSONArray;
    .end local v3    # "e":Ljava/io/IOException;
    :cond_70
    :try_start_70
    new-instance v2, Lorg/json/JSONObject;

    invoke-direct {v2}, Lorg/json/JSONObject;-><init>()V
    :try_end_75
    .catch Ljava/io/IOException; {:try_start_70 .. :try_end_75} :catch_8a
    .catch Lcom/google/gson/JsonParseException; {:try_start_70 .. :try_end_75} :catch_9a
    .catch Lorg/json/JSONException; {:try_start_70 .. :try_end_75} :catch_a1
    .catchall {:try_start_70 .. :try_end_75} :catchall_91

    .line 92
    :try_start_75
    invoke-interface {p1}, Lretrofit/mime/TypedInput;->in()Ljava/io/InputStream;

    move-result-object v6

    invoke-virtual {v6}, Ljava/io/InputStream;->close()V
    :try_end_7c
    .catch Ljava/io/IOException; {:try_start_75 .. :try_end_7c} :catch_7d

    goto :goto_42

    .line 93
    :catch_7d
    move-exception v3

    .line 94
    .restart local v3    # "e":Ljava/io/IOException;
    invoke-virtual {v3}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_42

    .line 81
    .end local v3    # "e":Ljava/io/IOException;
    :cond_82
    :try_start_82
    new-instance v6, Lretrofit/converter/ConversionException;

    const-string v7, "result is not true."

    invoke-direct {v6, v7}, Lretrofit/converter/ConversionException;-><init>(Ljava/lang/String;)V

    throw v6
    :try_end_8a
    .catch Ljava/io/IOException; {:try_start_82 .. :try_end_8a} :catch_8a
    .catch Lcom/google/gson/JsonParseException; {:try_start_82 .. :try_end_8a} :catch_9a
    .catch Lorg/json/JSONException; {:try_start_82 .. :try_end_8a} :catch_a1
    .catchall {:try_start_82 .. :try_end_8a} :catchall_91

    .line 84
    .end local v4    # "json":Ljava/lang/String;
    .end local v5    # "jsonObject":Lorg/json/JSONObject;
    :catch_8a
    move-exception v3

    .line 85
    .restart local v3    # "e":Ljava/io/IOException;
    :try_start_8b
    new-instance v6, Lretrofit/converter/ConversionException;

    invoke-direct {v6, v3}, Lretrofit/converter/ConversionException;-><init>(Ljava/lang/Throwable;)V

    throw v6
    :try_end_91
    .catchall {:try_start_8b .. :try_end_91} :catchall_91

    .line 91
    .end local v3    # "e":Ljava/io/IOException;
    :catchall_91
    move-exception v6

    .line 92
    :try_start_92
    invoke-interface {p1}, Lretrofit/mime/TypedInput;->in()Ljava/io/InputStream;

    move-result-object v7

    invoke-virtual {v7}, Ljava/io/InputStream;->close()V
    :try_end_99
    .catch Ljava/io/IOException; {:try_start_92 .. :try_end_99} :catch_a8

    .line 95
    :goto_99
    throw v6

    .line 86
    :catch_9a
    move-exception v3

    .line 87
    .local v3, "e":Lcom/google/gson/JsonParseException;
    :try_start_9b
    new-instance v6, Lretrofit/converter/ConversionException;

    invoke-direct {v6, v3}, Lretrofit/converter/ConversionException;-><init>(Ljava/lang/Throwable;)V

    throw v6

    .line 88
    .end local v3    # "e":Lcom/google/gson/JsonParseException;
    :catch_a1
    move-exception v3

    .line 89
    .local v3, "e":Lorg/json/JSONException;
    new-instance v6, Lretrofit/converter/ConversionException;

    invoke-direct {v6, v3}, Lretrofit/converter/ConversionException;-><init>(Ljava/lang/Throwable;)V

    throw v6
    :try_end_a8
    .catchall {:try_start_9b .. :try_end_a8} :catchall_91

    .line 93
    .end local v3    # "e":Lorg/json/JSONException;
    :catch_a8
    move-exception v3

    .line 94
    .local v3, "e":Ljava/io/IOException;
    invoke-virtual {v3}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_99
.end method

.method public toBody(Ljava/lang/Object;)Lretrofit/mime/TypedOutput;
    .registers 6
    .param p1, "object"    # Ljava/lang/Object;

    .prologue
    .line 102
    :try_start_0
    new-instance v1, Lcom/brixd/niceapp/service/adapter/JsonObjectConverter$JsonTypedOutput;

    new-instance v2, Lcom/google/gson/Gson;

    invoke-direct {v2}, Lcom/google/gson/Gson;-><init>()V

    invoke-virtual {v2, p1}, Lcom/google/gson/Gson;->toJson(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v2

    iget-object v3, p0, Lcom/brixd/niceapp/service/adapter/JsonObjectConverter;->encoding:Ljava/lang/String;

    invoke-virtual {v2, v3}, Ljava/lang/String;->getBytes(Ljava/lang/String;)[B

    move-result-object v2

    iget-object v3, p0, Lcom/brixd/niceapp/service/adapter/JsonObjectConverter;->encoding:Ljava/lang/String;

    invoke-direct {v1, v2, v3}, Lcom/brixd/niceapp/service/adapter/JsonObjectConverter$JsonTypedOutput;-><init>([BLjava/lang/String;)V
    :try_end_16
    .catch Ljava/io/UnsupportedEncodingException; {:try_start_0 .. :try_end_16} :catch_17

    return-object v1

    .line 103
    :catch_17
    move-exception v0

    .line 104
    .local v0, "e":Ljava/io/UnsupportedEncodingException;
    new-instance v1, Ljava/lang/AssertionError;

    invoke-direct {v1, v0}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V

    throw v1
.end method
